<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <!-- 引包 -->
    <script src="../js/vue.js"></script>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        ul{
            width: 150px;
            list-style: none;
            background: yellowgreen;
        }
        li{
            width: 100%;
            height: 50px;
            text-align: center;
            line-height: 50px;
            border-bottom: 1px solid white;
            color: white;
        }
        .active{
            background: red;
        }
    </style>
</head>
<body>
    <!-- 容器|模板 -->
    <div id="app">

        <ul>
            <li v-for="(item,index) in list" :key="item.id" @mouseenter="handle(index)" :class="{active : currentIndex===index}">{{item.title}}</li>
        </ul>
    </div>
</body>
</html>
<script>
     //关联VM
     const VM = new Vue({
         el:'#app',
         data:{
            list: [
                { id: 1001, title: '母婴' },
                { id: 2021, title: '家电' },
                { id: 3789, title: '医用' },
                { id: 4214, title: '手机' },
                { id: 532, title: '直播' },
                { id: 699, title: '游戏' },
                { id: 732, title: '酒水' },
                { id: 8123, title: '娱乐' },
                { id: 991, title: '美食' },
                { id: 101, title:'财经' }
            ],
            currentIndex :0
         },
         methods:{
             handle(index){
                 this.currentIndex = index
             }
         }
     })
</script>